Installing MySQL 9.7 LTS Community Edition on CentOS

Installing MySQL 9.7 LTS Community Edition on CentOS

Historically installing MySQL on a RedHat Compatible Linux server was as simple as yum install mysql-server.

Today’s MySQL Oracle Linux, Red Hat Enterprise Linux, CentOS, and Fedora 9.7 instructions are not accurate mixing in 8.4 and 8.0 information, and GenAI can also mislead you for the installation process. The most notable issue that I’d like to resolve is correct GPG Key checking, currently this is disabled --nogpgcheck as 2025 key does not operate as expected.

The following is my cloud-init.yml file I use to build VMs with OrbStack . In summary:

  • Define correct yum repos
  • Install with GPG disabled
  • Enable Service
  • Set a usable (aka non-temporary) root password

cloud-init.yml

#cloud-config
# MySQL 9.7 LTS install for CentOS Stream 9 (works on aarch64/ARM64).
#
# Notes:
#  - The repo URL path is mysql-9.7-community (NOT mysql-9.7-lts-community);
#    only the repo *id* carries the -lts- label.
#  - MySQL's published GPG key file still shows expired (2025-10-22) even
#    though the key was re-extended, and the RPM-GPG-KEY-mysql-2025 URL is
#    empty. So gpgcheck is disabled here to keep an unattended boot from
#    failing. Re-enable once MySQL refreshes the published key file.

write_files:
  - path: /etc/yum.repos.d/mysql-community.repo
    permissions: '0644'
    owner: root:root
    content: |
      [mysql-9.7-lts-community]
      name=MySQL 9.7 LTS Community Server
      baseurl=https://repo.mysql.com/yum/mysql-9.7-community/el/9/$basearch/
      enabled=1
      gpgcheck=0

      [mysql-connectors-community]
      name=MySQL Connectors Community
      baseurl=https://repo.mysql.com/yum/mysql-connectors-community/el/9/$basearch/
      enabled=1
      gpgcheck=0

      [mysql-tools-community]
      name=MySQL Tools Community
      baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/9/$basearch/
      enabled=1
      gpgcheck=0

runcmd:
  - dnf clean all
  - dnf install -y --nogpgcheck mysql-community-server
  - systemctl enable --now mysqld
  - mysql --version
  # Rotate the generated temporary root password to a fresh random one.
  - [ sh, -c, "OLD_PASSWD=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'); PASSWD=\"#A$(date | md5sum | cut -c1-12)\"; echo \"ALTER USER root@localhost IDENTIFIED BY '${PASSWD}';\" | mysql -uroot -p\"${OLD_PASSWD}\" --connect-expired-password; echo \"${PASSWD}\" > /root/.mysql.password; chmod 600 /root/.mysql.password" ]

Installation Demo

Full installation instructions with orb installed and using mysql97.yml

wget https://gist.githubusercontent.com/ronaldbradford/672ebd49fc0ab0a092f74bec23461ff6/raw/9424a0f8b54b5b79356182aa8f119676cf60280f/mysql97.yml
VM_NAME="centos10"
orb create centos ${VM_NAME} -c mysql97.yml
orb -m ${VM_NAME} tail /var/log/cloud-init-output.log
ssh ${VM_NAME}@orb
PASSWD=$(sudo cat /root/.mysql.password)
mysql -uroot -p${PASSWD} -e "SELECT VERSION()"
Tagged with: MySQL 9.7 Installation

Related Posts

A first look at MySQL 26.7 Early Access

MySQL has dropped its newest release , categorized as “Early Access” and available at https://labs.mysql.com/ . While this post is not going to go into depth, I wanted to at least validate the management changes you verify between normal MySQL upgrades.

Read more

Where is the technology breakdown? Can AI help?

On a major financial institution website I was asked to complete a contact form. This organization has millions of existing customers. This is not a startup, yet the quality of work is something a junior developer would fail at an interview if they provided the answer.

Read more

Why My Mac Was Not Using Post-Quantum SSH With GitHub (And How I Fixed It)

In my previous post I made the case that the only post-quantum protection that counts is the algorithm your connection actually negotiates. This post is what happened when I checked my own laptop.

Read more